/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Douglas
 */
public class ThreadTimer extends Thread {

    private int time;
    private Carro car;

    public ThreadTimer(int time, Carro car) {
        this.time = time;
        this.car = car;
    }

    @Override
    public void run() {

        for (int j = 1; j <= time; j++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(ThreadTimer.class.getName()).log(Level.SEVERE, null, ex);
            }
            if ((j % 2) == 0) {
                car.setTime(time, (j / 2) - 1);
            } else {
                car.setTime(time, -1);
            }
        }
        car.setAtravessou();
    }
}
